package org.jsola.hr.helper;

import org.jsola.hr.dto.SocPlanFeedbackRecordAddDTO;
import org.jsola.hr.dto.SocPlanFeedbackRecordUpdateDTO;
import org.jsola.hr.entity.SocPlanFeedbackRecordDO;
import org.jsola.hr.query.SocPlanFeedbackRecordQuery;
import org.jsola.hr.service.ISocPlanFeedbackRecordService;
import org.jsola.hr.vo.SocPlanFeedbackRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 增减员计划反馈记录表
 *
 * @author zhr
 */
@Component
public class SocPlanFeedbackRecordTestHelper extends BaseTestHelper {
    
    @Autowired
    private ISocPlanFeedbackRecordService socPlanFeedbackRecordService;

    /**
     * 生成add测试数据
     * @return SocPlanFeedbackRecordAddDTO
     */
    public SocPlanFeedbackRecordAddDTO getSocPlanFeedbackRecordAddDTO(){
        SocPlanFeedbackRecordAddDTO socPlanFeedbackRecordAddDTO = new SocPlanFeedbackRecordAddDTO();
        socPlanFeedbackRecordAddDTO.setPlanId(getRandomValue("varchar",32));
        socPlanFeedbackRecordAddDTO.setUserId(getRandomValue("varchar",32));
        socPlanFeedbackRecordAddDTO.setAnnex(getRandomValue("varchar",2000));
        socPlanFeedbackRecordAddDTO.setFeedbackContent(getRandomValue("varchar",255));
        socPlanFeedbackRecordAddDTO.setRemark(getRandomValue("varchar",255));
        socPlanFeedbackRecordAddDTO.setFeedbackState(getRandomValue("varchar",50));
        return socPlanFeedbackRecordAddDTO;
    }


    /**
     * 生成update测试数据
     * @return SocPlanFeedbackRecordUpdateDTO
     */
    public SocPlanFeedbackRecordUpdateDTO getSocPlanFeedbackRecordUpdateDTO(SocPlanFeedbackRecordVO socPlanFeedbackRecordVO){
        return socPlanFeedbackRecordService.selectDOById(socPlanFeedbackRecordVO.getId(), SITE_ID).to(SocPlanFeedbackRecordUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return SocPlanFeedbackRecordQuery
     */
    public SocPlanFeedbackRecordQuery getSocPlanFeedbackRecordQuery() {
        SocPlanFeedbackRecordQuery socPlanFeedbackRecordQuery = new SocPlanFeedbackRecordQuery();
        List<SocPlanFeedbackRecordDO> socPlanFeedbackRecordDOList = socPlanFeedbackRecordService.list(new SocPlanFeedbackRecordDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(socPlanFeedbackRecordDOList)) {
            SocPlanFeedbackRecordDO socPlanFeedbackRecordDO = socPlanFeedbackRecordDOList.get(0);
            socPlanFeedbackRecordQuery = socPlanFeedbackRecordDO.to(SocPlanFeedbackRecordQuery.class);
        }
        return socPlanFeedbackRecordQuery;
    }

    /**
     * 保存示例
     * @return SocPlanFeedbackRecordVO
     */
    public SocPlanFeedbackRecordVO saveSocPlanFeedbackRecordExample(){
        SocPlanFeedbackRecordAddDTO addDTO = this.getSocPlanFeedbackRecordAddDTO();
        SocPlanFeedbackRecordVO socPlanFeedbackRecordVO = socPlanFeedbackRecordService.save(addDTO,buildTokenUser());
        return socPlanFeedbackRecordVO;
    }


}

